import sys
import argparse
import re

import py3func

def getopt():
    parser = argparse.ArgumentParser("gen_pyc.py", description="Python Compiling Generator【v0.0.1】2018/09/01")
    parser.add_argument("path_src", action="store", help="the source dir to compile")
    parser.add_argument("-e", "--extract", action="store", help="extract the pyc from __pychche__ recursively, and point the build_dir")
    parser.add_argument("-f", "--force", action="store_true", help="update the pyc forcely")
    return parser.parse_args()

if __name__ == "__main__":
    args = getopt()
    force = True if args.force else False
    # build the pyc
    py3func.make_pyc(args.path_src, r"test.*", force)

    # extract __pycache__
    if args.extract:
        py3func.extract_pyc(args.path_src, args.extract)
